﻿using System;
using BlizzardApi;
using Model;
using StructureMap;
using Utility;

namespace Command.Framework
{
	public class StructureMapResolver : IResolver
	{
		static StructureMapResolver()
		{
			ObjectFactory.Initialize(x =>
			{
				x.UseDefaultStructureMapConfigFile = false;
				x.Scan(scan =>
				{
					scan.WithDefaultConventions();
					scan.AssemblyContainingType<WowService>();
					scan.AssemblyContainingType<CommandRegistry>();
					scan.AssemblyContainingType<Character>();
					scan.LookForRegistries();
				});
			});
		}

		public T Resolve<T>()
		{
			return ObjectFactory.GetInstance<T>();
		}

		public T Resolve<T>(Type subType)
		{
			return (T)ObjectFactory.GetInstance(subType);
		}
	}
}
